package com.chukun.flink.stream.kafka;

import com.alibaba.fastjson.JSON;
import com.chukun.flink.stream.bean.KafkaMess;
import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.typeinfo.TypeInformation;

import java.io.IOException;

/**
 * @author chukun
 * @version 1.0.0
 * @description kafka消息反序列化
 * @createTime 2022年06月04日 11:43:00
 */
public class KafkaMessageDeserializer implements DeserializationSchema<KafkaMess> {
    @Override
    public KafkaMess deserialize(byte[] message) throws IOException {
        return JSON.parseObject(message, KafkaMess.class);
    }

    @Override
    public boolean isEndOfStream(KafkaMess kafkaMess) {
        return false;
    }

    @Override
    public TypeInformation<KafkaMess> getProducedType() {
        return TypeInformation.of(KafkaMess.class);
    }
}
